feat(dropdown): add opt-in close-on-click attribute#169
Open
Vikram-Hegde wants to merge 1 commit into
Open
Conversation
Add a `close-on-click` attribute on `<ot-dropdown>` that closes the popover as soon as a `role="menuitem"` is clicked. Default behavior is unchanged (popover stays open on item click).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds an opt-in
close-on-clickattribute on<ot-dropdown>that automatically dismisses the popover as soon as arole="menuitem"is clicked.Why
Previously, clicking a menu item inside a
<ot-dropdown>popover did not close the popover — it only closed on an outside click or another toggle. For in-page actions (e.g. toggling a theme, muting a channel, switching a view) that don't trigger a navigation or page refresh, the dropdown stayed open and the user had to dismiss it manually. That made the menu feel sticky and broke the expected menu UX.With
close-on-click, the popover closes immediately on item click, giving the expected "menu item activates and the menu disappears" behavior — without forcing it on use cases that do rely on the popover staying open (e.g. forms, multi-step confirmations).Usage
The default behavior is unchanged: the attribute is opt-in, and popovers without it still stay open on item click.